#include <iostream>
#include<sys/time.h>
#include<unistd.h>
using namespace std;
int* a, * b;
const int n = 300000;//规定是偶数，方便二路算法计算


int main()
{
    a = new int [n];
    b = new int[n];
    //初始化记录数据的数组
    for (int i = 0; i < n; i++)
    {
        a[i] = rand() % 100;
        b[i] = a[i];
    }
    //多链路是算法
    int solution2 = 0;
    int* solution22 = new int[2];
    solution22[0] = 0;
    solution22[1] = 0;

    struct timeval start2;
    struct timeval end2;
    gettimeofday(&start2, NULL);
    for (int i = 0; i < n-1; i = i+2)
    {
        solution22[0] += a[i];
        solution22[1] += a[i+1];
    }
    solution2 = solution22[0] + solution22[1];
    gettimeofday(&end2, NULL);
    cout << "多链路式: " << end2.tv_sec - start2.tv_sec << "ms" << endl;

}